package search;

import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.Arrays;

public class a {
    public static void main(String[] args) {
        Object o=new Object();
        System.out.println(o);
        Object o2=new Object();
        SoftReference<String> s1=new SoftReference<>(new String("Hello"));
        System.out.println(s1);
        o2=null;
        System.out.println(s1);


        WeakReference<String> s2=new WeakReference<String>(new String("hello"));
        System.out.println(s2.get());
        System.gc();
        System.out.println(s2.get());

        WeakReference<String> sr = new WeakReference<String>(new String("hello"));
        System.out.println(sr.get());
        System.gc();                //通知JVM的gc进行垃圾回收
        System.out.println(sr.get());


//        int[] arr={4,7,6,2};
//        System.out.println(b(arr));
    }
    public static int b(int[] arr){
        int[] res=new int[arr.length];
        res[0]=arr[0];
        res[1]=Math.max(arr[0],arr[1]);
        for(int i=2;i<arr.length;i++){
            res[i]=Math.max(res[i-1],res[i-2]+arr[i]);
        }
        System.out.println(Arrays.toString(res));
        return res[arr.length-1];
    }
}
